#include "TwitterV2UI.h"
#include "vmgraph.h"

VMINT screen_width;
VMINT screen_height;
VMINT cur_lcd_support;

VMSTR img_name[IMG_ID_END];
struct twitter_ui_struct twitter_ui;

void lcd_support_init(void)
{
	screen_width = vm_graphic_get_screen_width();
	screen_height = vm_graphic_get_screen_height();

	if(QCIF_WIDTH == screen_width && QCIF_HEIGHT == screen_height)
	{
		cur_lcd_support = ENUM_SUPPORT_QCIF;
	}
	else if(QCIF_LS_WIDTH == screen_width && QCIF_LS_HEIGHT == screen_height)
	{
		cur_lcd_support = ENUM_SUPPORT_QCIF_LS;
	}
	if(QVGA_WIDTH == screen_width && QVGA_HEIGHT == screen_height)
	{
		cur_lcd_support = ENUM_SUPPORT_QVGA;
	}
	else if(QVGA_LS_WIDTH == screen_width && QVGA_LS_HEIGHT == screen_height)
	{
		cur_lcd_support = ENUM_SUPPORT_QVGA_LS;
	}
	if(WQVGA_WIDTH == screen_width && WQVGA_HEIGHT == screen_height)
	{
		cur_lcd_support = ENUM_SUPPORT_WQVGA;
	}
	
	switch(cur_lcd_support)
	{
	case ENUM_SUPPORT_QCIF:
		img_name[IMG_ID_LOGIN_BG] = "176X220_login_bg.gif";
		img_name[IMG_ID_LOGIN_BTN_BG] = "176X220_login_btnbar.gif";
		img_name[IMG_ID_MAIN_ARROW] = "mainwnd_arrow.gif";

		twitter_ui.login_label_user.left = 5;
		twitter_ui.login_label_user.top = 80;
		twitter_ui.login_label_user.right = screen_width - 5;
		twitter_ui.login_label_user.bottom = twitter_ui.login_label_user.top + 24;
		
		twitter_ui.login_edit_user.left = 5;
		twitter_ui.login_edit_user.top = twitter_ui.login_label_user.bottom;
		twitter_ui.login_edit_user.right = screen_width - 5;
		twitter_ui.login_edit_user.bottom = twitter_ui.login_edit_user.top + 24;

		twitter_ui.login_label_pass.left = 5;
		twitter_ui.login_label_pass.top = twitter_ui.login_edit_user.bottom;
		twitter_ui.login_label_pass.right = screen_width - 5;
		twitter_ui.login_label_pass.bottom = twitter_ui.login_label_pass.top + 24;
		
		twitter_ui.login_edit_pass.left = 5;
		twitter_ui.login_edit_pass.top = twitter_ui.login_label_pass.bottom;
		twitter_ui.login_edit_pass.right = screen_width - 5;
		twitter_ui.login_edit_pass.bottom = twitter_ui.login_edit_pass.top + 24;

		twitter_ui.main_top_tab.left = 0;
		twitter_ui.main_top_tab.top = 0;
		twitter_ui.main_top_tab.right = screen_width;
		twitter_ui.main_top_tab.bottom = twitter_ui.main_top_tab.top + 26;

		twitter_ui.main_mid_listbox.left = 0;
		twitter_ui.main_mid_listbox.top = twitter_ui.main_top_tab.bottom;
		twitter_ui.main_mid_listbox.right = screen_width;
		twitter_ui.main_mid_listbox.bottom = screen_height - 26;

		twitter_ui.main_btm_mid_btn.left = 58;
		twitter_ui.main_btm_mid_btn.top = screen_height - 26;
		twitter_ui.main_btm_mid_btn.right = 176 - 58;
		twitter_ui.main_btm_mid_btn.bottom = screen_height;

		twitter_ui.softkey_bar.left = 0;
		twitter_ui.softkey_bar.top = screen_height - 26;
		twitter_ui.softkey_bar.right = screen_width;
		twitter_ui.softkey_bar.bottom = screen_height;
		break;
	case ENUM_SUPPORT_QCIF_LS:
		img_name[IMG_ID_LOGIN_BG] = "220X176_login_bg.gif";
		img_name[IMG_ID_LOGIN_BTN_BG] = "220X176_login_btnbar.gif";
		img_name[IMG_ID_MAIN_ARROW] = "mainwnd_arrow.gif";
		
		twitter_ui.login_label_user.left = 5;
		twitter_ui.login_label_user.top = 68;
		twitter_ui.login_label_user.right = screen_width - 5;
		twitter_ui.login_label_user.bottom = twitter_ui.login_label_user.top + 20;
		
		twitter_ui.login_edit_user.left = 5;
		twitter_ui.login_edit_user.top = twitter_ui.login_label_user.bottom;
		twitter_ui.login_edit_user.right = screen_width - 5;
		twitter_ui.login_edit_user.bottom = twitter_ui.login_edit_user.top + 20;

		twitter_ui.login_label_pass.left = 5;
		twitter_ui.login_label_pass.top = twitter_ui.login_edit_user.bottom;
		twitter_ui.login_label_pass.right = screen_width - 5;
		twitter_ui.login_label_pass.bottom = twitter_ui.login_label_pass.top + 20;
		
		twitter_ui.login_edit_pass.left = 5;
		twitter_ui.login_edit_pass.top = twitter_ui.login_label_pass.bottom;
		twitter_ui.login_edit_pass.right = screen_width - 5;
		twitter_ui.login_edit_pass.bottom = twitter_ui.login_edit_pass.top + 20;

		twitter_ui.main_top_tab.left = 0;
		twitter_ui.main_top_tab.top = 0;
		twitter_ui.main_top_tab.right = screen_width;
		twitter_ui.main_top_tab.bottom = twitter_ui.main_top_tab.top + 26;

		twitter_ui.main_mid_listbox.left = 0;
		twitter_ui.main_mid_listbox.top = twitter_ui.main_top_tab.bottom;
		twitter_ui.main_mid_listbox.right = screen_width;
		twitter_ui.main_mid_listbox.bottom = screen_height - 26;

		twitter_ui.main_btm_mid_btn.left = 73;
		twitter_ui.main_btm_mid_btn.top = screen_height - 26;
		twitter_ui.main_btm_mid_btn.right = 220 - 73;
		twitter_ui.main_btm_mid_btn.bottom = screen_height;

		twitter_ui.softkey_bar.left = 0;
		twitter_ui.softkey_bar.top = screen_height - 26;
		twitter_ui.softkey_bar.right = screen_width;
		twitter_ui.softkey_bar.bottom = screen_height;
		break;
	case ENUM_SUPPORT_QVGA:
		img_name[IMG_ID_LOGIN_BG] = "240X320_login_bg.gif";
		img_name[IMG_ID_LOGIN_BTN_BG] = "240X320_login_btnbar.gif";
		img_name[IMG_ID_MAIN_ARROW] = "mainwnd_arrow.gif";
		
		twitter_ui.login_label_user.left = 5;
		twitter_ui.login_label_user.top = 94;
		twitter_ui.login_label_user.right = screen_width - 5;
		twitter_ui.login_label_user.bottom = twitter_ui.login_label_user.top + 24;
		
		twitter_ui.login_edit_user.left = 5;
		twitter_ui.login_edit_user.top = twitter_ui.login_label_user.bottom;
		twitter_ui.login_edit_user.right = screen_width - 5;
		twitter_ui.login_edit_user.bottom = twitter_ui.login_edit_user.top + 24;

		twitter_ui.login_label_pass.left = 5;
		twitter_ui.login_label_pass.top = twitter_ui.login_edit_user.bottom;
		twitter_ui.login_label_pass.right = screen_width - 5;
		twitter_ui.login_label_pass.bottom = twitter_ui.login_label_pass.top + 24;
		
		twitter_ui.login_edit_pass.left = 5;
		twitter_ui.login_edit_pass.top = twitter_ui.login_label_pass.bottom;
		twitter_ui.login_edit_pass.right = screen_width - 5;
		twitter_ui.login_edit_pass.bottom = twitter_ui.login_edit_pass.top + 24;

		twitter_ui.main_top_tab.left = 0;
		twitter_ui.main_top_tab.top = 0;
		twitter_ui.main_top_tab.right = screen_width;
		twitter_ui.main_top_tab.bottom = twitter_ui.main_top_tab.top + 30;

		twitter_ui.main_mid_listbox.left = 0;
		twitter_ui.main_mid_listbox.top = twitter_ui.main_top_tab.bottom;
		twitter_ui.main_mid_listbox.right = screen_width;
		twitter_ui.main_mid_listbox.bottom = screen_height - 30;

		twitter_ui.main_btm_mid_btn.left = 80;
		twitter_ui.main_btm_mid_btn.top = screen_height - 30;
		twitter_ui.main_btm_mid_btn.right = 160;
		twitter_ui.main_btm_mid_btn.bottom = screen_height;

		twitter_ui.softkey_bar.left = 0;
		twitter_ui.softkey_bar.top = screen_height - 30;
		twitter_ui.softkey_bar.right = screen_width;
		twitter_ui.softkey_bar.bottom = screen_height;
		
		break;
	case ENUM_SUPPORT_QVGA_LS:
		img_name[IMG_ID_LOGIN_BG] = "320X240_login_bg.gif";
		img_name[IMG_ID_LOGIN_BTN_BG] = "320X240_login_btnbar.gif";
		img_name[IMG_ID_MAIN_ARROW] = "mainwnd_arrow.gif";

		twitter_ui.login_label_user.left = 5;
		twitter_ui.login_label_user.top = 86;
		twitter_ui.login_label_user.right = screen_width - 5;
		twitter_ui.login_label_user.bottom = twitter_ui.login_label_user.top + 24;
		
		twitter_ui.login_edit_user.left = 5;
		twitter_ui.login_edit_user.top = twitter_ui.login_label_user.bottom;
		twitter_ui.login_edit_user.right = screen_width - 5;
		twitter_ui.login_edit_user.bottom = twitter_ui.login_edit_user.top + 24;

		twitter_ui.login_label_pass.left = 5;
		twitter_ui.login_label_pass.top = twitter_ui.login_edit_user.bottom;
		twitter_ui.login_label_pass.right = screen_width - 5;
		twitter_ui.login_label_pass.bottom = twitter_ui.login_label_pass.top + 24;
		
		twitter_ui.login_edit_pass.left = 5;
		twitter_ui.login_edit_pass.top = twitter_ui.login_label_pass.bottom;
		twitter_ui.login_edit_pass.right = screen_width - 5;
		twitter_ui.login_edit_pass.bottom = twitter_ui.login_edit_pass.top + 24;

		twitter_ui.main_top_tab.left = 0;
		twitter_ui.main_top_tab.top = 0;
		twitter_ui.main_top_tab.right = screen_width;
		twitter_ui.main_top_tab.bottom = twitter_ui.main_top_tab.top + 30;

		twitter_ui.main_mid_listbox.left = 0;
		twitter_ui.main_mid_listbox.top = twitter_ui.main_top_tab.bottom;
		twitter_ui.main_mid_listbox.right = screen_width;
		twitter_ui.main_mid_listbox.bottom = screen_height - 30;

		twitter_ui.main_btm_mid_btn.left = 106;
		twitter_ui.main_btm_mid_btn.top = screen_height - 30;
		twitter_ui.main_btm_mid_btn.right = 320 - 106;
		twitter_ui.main_btm_mid_btn.bottom = screen_height;

		twitter_ui.softkey_bar.left = 0;
		twitter_ui.softkey_bar.top = screen_height - 30;
		twitter_ui.softkey_bar.right = screen_width;
		twitter_ui.softkey_bar.bottom = screen_height;
		break;
	case ENUM_SUPPORT_WQVGA:
		img_name[IMG_ID_LOGIN_BG] = "240X400_login_bg.gif";
		img_name[IMG_ID_LOGIN_BTN_BG] = "240X400_login_btnbar.gif";
		img_name[IMG_ID_MAIN_ARROW] = "mainwnd_arrow.gif";
		
		twitter_ui.login_label_user.left = 5;
		twitter_ui.login_label_user.top = 134;
		twitter_ui.login_label_user.right = screen_width - 5;
		twitter_ui.login_label_user.bottom = twitter_ui.login_label_user.top + 24;
		
		twitter_ui.login_edit_user.left = 5;
		twitter_ui.login_edit_user.top = twitter_ui.login_label_user.bottom;
		twitter_ui.login_edit_user.right = screen_width - 5;
		twitter_ui.login_edit_user.bottom = twitter_ui.login_edit_user.top + 24;

		twitter_ui.login_label_pass.left = 5;
		twitter_ui.login_label_pass.top = twitter_ui.login_edit_user.bottom;
		twitter_ui.login_label_pass.right = screen_width - 5;
		twitter_ui.login_label_pass.bottom = twitter_ui.login_label_pass.top + 24;
		
		twitter_ui.login_edit_pass.left = 5;
		twitter_ui.login_edit_pass.top = twitter_ui.login_label_pass.bottom;
		twitter_ui.login_edit_pass.right = screen_width - 5;
		twitter_ui.login_edit_pass.bottom = twitter_ui.login_edit_pass.top + 24;

		twitter_ui.main_top_tab.left = 0;
		twitter_ui.main_top_tab.top = 0;
		twitter_ui.main_top_tab.right = screen_width;
		twitter_ui.main_top_tab.bottom = twitter_ui.main_top_tab.top + 30;

		twitter_ui.main_mid_listbox.left = 0;
		twitter_ui.main_mid_listbox.top = twitter_ui.main_top_tab.bottom;
		twitter_ui.main_mid_listbox.right = screen_width;
		twitter_ui.main_mid_listbox.bottom = screen_height - 30;

		twitter_ui.main_btm_mid_btn.left = 80;
		twitter_ui.main_btm_mid_btn.top = screen_height - 30;
		twitter_ui.main_btm_mid_btn.right = 160;
		twitter_ui.main_btm_mid_btn.bottom = screen_height;

		twitter_ui.softkey_bar.left = 0;
		twitter_ui.softkey_bar.top = screen_height - 30;
		twitter_ui.softkey_bar.right = screen_width;
		twitter_ui.softkey_bar.bottom = screen_height;
		break;
	}
}

VMSTR get_img_name(VMINT index)
{
	return img_name[index];
}

